#!/bin/bash

#输入hostname
#hostnamectl set-hostname $1

#设置swap为0
sed -i '/vm.swappiness/d' /etc/sysctl.conf
echo "vm.swappiness = 0" >> /etc/sysctl.conf
#使配置生效
sysctl -p

# 设置透明大页面
echo never > /sys/kernel/mm/transparent_hugepage/defrag
cat /sys/kernel/mm/transparent_hugepage/defrag
echo never > /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/enabled
#设置开机自关闭
sed -i '/transparent_hugepage/d' /etc/rc.d/rc.local
echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.d/rc.local
echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.d/rc.local
cat /etc/rc.d/rc.local

yum -y install epel-release
yum -y install rsync
yum -y install rng-tools
yum -y install iptables-services
yum -y install lrzsz
yum -y install vim
yum -y install net-tools
yum -y install createrepo
yum -y install telnet
yum -y install password
yum -y install tcl
yum -y install expect
yum -y install libaio
yum -y install bind-utils
yum -y install chkconfig
yum -y install cyrus-sasl-gssapi
yum -y install cyrus-sasl-plain
yum -y install fuse
yum -y install fuse-libs
yum -y install gcc
yum -y install libxslt
yum -y install mod_ssl
yum -y install MySQL-python
yum -y install openssl
yum -y install openssl-devel
yum -y install perl
yum -y install portmap
yum -y install postgresql-server
yum -y install psmisc
yum -y install python-devel
yum -y install python-psycopg2
yum -y install python-setuptools
yum -y install sed
yum -y install sqlite
yum -y install swig
yum -y install zlib
yum -y install ntpdate

setenforce 0
#将显示SELinux启用状态
sestatus -v
chkconfig iptables off
systemctl disable iptables
service iptables stop
service iptables status
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
swapoff -a

sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

echo "# Generated by NetworkManager
nameserver 114.114.114.114
nameserver 223.5.5.5
nameserver 8.8.8.8
nameserver 119.29.29.29
" > /etc/resolv.conf

systemctl restart NetworkManager
systemctl restart network

#安装rngd服务
cp /usr/lib/systemd/system/rngd.service /etc/systemd/system/
sed -i -e 's/ExecStart=\/sbin\/rngd -f/ExecStart=\/sbin\/rngd -f -r \/dev\/urandom/' /etc/systemd/system/rngd.service
systemctl daemon-reload
systemctl start rngd
systemctl enable rngd